package com.jt.controller;

import com.jt.pojo.ItemCat;
import com.jt.service.ItemCatService;
import com.jt.vo.EasyUITree;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/item/cat")
public class ItemCatController {

    @Autowired
    private ItemCatService itemCatService;

    //获取叶子类目名称
    @RequestMapping("/queryItemName")
    public String queryItemName(Long itemCatId){
        ItemCat itemCat=itemCatService.queryItemName(itemCatId);
        return itemCat.getName();
    }

    //商品分类树形展现
    @RequestMapping("/list")
    public List<EasyUITree> findItemCatList(Long id){
        Long parentId=(id==null)?0:id;
        List<EasyUITree> list=itemCatService.findItemCatList(parentId);
        //List<EasyUITree> list=itemCatService.findItemCatCache(parentId);
        //System.out.println(list);
        return list;
    }

}
